const sessionStorageHandler = {
	name: 'erp-sanhui',
	setItem: function(name, value) {
		let obj = JSON.parse(window.sessionStorage.getItem(this.name))
		if(obj == null) {
			obj = {}
		}
		obj[name] = value
		window.sessionStorage.setItem(this.name, JSON.stringify(obj))
	},
	delItem: function(name) {
		let obj = JSON.parse(window.sessionStorage.getItem(this.name))
		if(obj === null) {
			return false
		} else {
			if(obj[name] !== undefined) {
				delete obj[name]
				window.sessionStorage.setItem(this.name, JSON.stringify(obj))
			}
		}
	},
	getItem: function(name) {
		let obj = JSON.parse(window.sessionStorage.getItem(this.name))
		if(obj !== null && obj[name] !== undefined) {
			return obj[name]
		} else {
			return null
		}
	},
	die: function() {
		window.sessionStorage.removeItem(this.name)
	},
	list: function() {}
}
window.SSH = sessionStorageHandler

export default sessionStorageHandler